﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.ModelBinding;

namespace Sharp.Platform
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class ColumnAttribute : Attribute//, IMetadataAware
    {
        private bool? _locked;
        private bool? _sortable;
        private bool? _cellWrap;
        [DefaultValue(false)]
        public virtual bool Ignore
        {
            get;
            set;
        }

        [DefaultValue(false)]
        public virtual bool HideTitleEl
        {
            get;
            set;
        }
        /// <summary>
        ///
        /// </summary>
        public virtual bool Locked
        {
            get
            {
                return this._locked.HasValue && this._locked.Value;
            }
            set
            {
                this._locked = new bool?(value);
            }
        }

        [DefaultValue(Alignment.Left)]
        public virtual Alignment Align { get; set; } = Alignment.Left;

        [DefaultValue(null)]
        public virtual string DataIndex
        {
            get;
            set;
        }

        [DefaultValue(true)]
        public virtual bool Draggable { get; set; } = true;

        [DefaultValue(null)]
        public virtual string EditorRendererHandler
        {
            get;
            set;
        }
        [DefaultValue(null)]
        public virtual string EmptyCellText
        {
            get;
            set;
        }

        [DefaultValue(true)]
        public virtual bool Groupable { get; set; } = true;

        [DefaultValue(true)]
        public virtual bool Hideable { get; set; } = true;

        [DefaultValue(false)]
        public virtual bool MenuDisabled
        {
            get;
            set;
        }

        [DefaultValue(null)]
        public virtual string MenuText
        {
            get;
            set;
        }

        [DefaultValue(null)]
        public virtual string RendererHandler
        {
            get;
            set;
        }

        [DefaultValue(null)]
        public virtual string Scope
        {
            get;
            set;
        }

        [DefaultValue(true)]
        public virtual bool Resizable { get; set; } = true;

        [DefaultValue(false)]
        public virtual bool Sealed
        {
            get;
            set;
        }

        public virtual bool Sortable
        {
            get
            {
                return !this._sortable.HasValue || this._sortable.Value;
            }
            set
            {
                this._sortable = new bool?(value);
            }
        }
        /// <summary>
        /// Optional. A CSS class names to apply to the table cells for this column.
        /// </summary>
        [DefaultValue(null)]
        public virtual string TdCls
        {
            get;
            set;
        }
        [DefaultValue(null)]
        public virtual string Text
        {
            get;
            set;
        }

        [DefaultValue(null)]
        public virtual string ToolTip
        {
            get;
            set;
        }
 

        public virtual bool CellWrap
        {
            get
            {
                return this._cellWrap.HasValue && this._cellWrap.Value;
            }
            set
            {
                this._cellWrap = new bool?(value);
            }
        }

        [DefaultValue(false)]
        public virtual bool Hidden
        {
            get;
            set;
        }

        [DefaultValue(0)]
        public virtual int Flex
        {
            get;
            set;
        }
        /// <summary>
        /// The width of this component in pixels.
        /// </summary>
        [DefaultValue(0)]
        public virtual int Width
        {
            get;
            set;
        }
        /// <summary>
        ///
        /// </summary>
        [DefaultValue(null)]
        public virtual string ID
        {
            get;
            set;
        }
        /// <summary>
        ///
        /// </summary>
        [DefaultValue(-1)]
        public virtual int Order { get; set; } = 2147483647;

        /// <summary>
        ///
        /// </summary>
        [DefaultValue(null)]
        public virtual Type EditorType { get; set; }

        public bool SearchFor { get; set; }
    }
}
